﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Data.OleDb;


namespace hj
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection("server=localhost; uid=NetCenterCashSystem; pwd=wangjie123; database=hospital");
            SqlCommand comm = new SqlCommand("select * from Doctor where dno = '" +textBox2.Text + "           '", conn);
            SqlDataReader reader;

            OleDbConnection conn2 = new OleDbConnection();

            conn.Open();

            reader = comm.ExecuteReader();
            int i = 0;
            //label1.Text = "";
            while (reader.Read())
            {
                //if (i == 0)
                {
                    for (int ii = 0; ii < reader.FieldCount; ii++)
                    {
                        textBox1.AppendText(reader.GetName(ii) + "\t | ");
                    }
                    textBox1.AppendText("\r\n");
                    i++;
                }


                for (int ii = 0; ii < reader.FieldCount; ii++)
                {
                    textBox1.Text += reader.GetValue(ii).ToString();
                    textBox1.Text += "\t   ";
                }
                textBox1.AppendText("\r\n");
                //label1.Text += reader.GetValue(0).ToString() + " || ";
                ////label1 = reader.GetValue(0).ToString();
                //textBox1.Text += reader.GetValue(0).ToString();
                ////textBox1.AppendText(reader.GetValue(0).ToString() + "\t|  " + reader.GetValue(1).ToString());
                ////textBox1.AppendText("\r\n");
            }

            conn.Close();
        }
    }
}
